package wtws.message;

import java.nio.ByteBuffer;

import wtws.message.interf.TdwrProdMessage;
import wtws.util.ByteUtil;

public class SystemStatusData implements TdwrProdMessage {

	public static final String TITLE = "System Status Data";
	public static final int MSG_ID = 12811;
	public static final int MSG_LEN = 8;

	public static final int MODE_MONITOR = 1;
	public static final int MODE_HAZARDOUS = 2;
	public static final int MODE_MAINT = 3;

	public static final int STATUS_NOGO = 0;
	public static final int STATUS_GO = 1;

	private static final long serialVersionUID = 1L;
	private int messageId;
	private int messageLength;
	private int tdwrMode;
	private int tdwrStatus;

	public SystemStatusData(int tdwrMode, int tdwrStatus) {
		this.messageId = MSG_ID;
		this.messageLength = MSG_LEN;
		this.tdwrMode = tdwrMode;
		this.tdwrStatus = tdwrStatus;
	}

	@Override
	public byte[] toByteArray() {
		ByteBuffer br = ByteBuffer.allocate(MSG_LEN);
		br.put(ByteUtil.to2Bytes(messageId));
		br.put(ByteUtil.to2Bytes(messageLength));
		br.put(ByteUtil.EMPTY_2B);
		br.put(ByteUtil.toByte(tdwrMode));
		br.put(ByteUtil.toByte(tdwrStatus));
		return br.array();
	}

	public int getMessageId() {
		return messageId;
	}

	public void setMessageId(int messageId) {
		this.messageId = messageId;
	}

	public int getTdwrMode() {
		return tdwrMode;
	}

	public void setTdwrMode(int tdwrMode) {
		this.tdwrMode = tdwrMode;
	}

	public int getTdwrStatus() {
		return tdwrStatus;
	}

	public void setTdwrStatus(int tdwrStatus) {
		this.tdwrStatus = tdwrStatus;
	}

	@Override
	public String getMessageTitle() {
		return TITLE;
	}

	public int getMessageLength() {
		return messageLength;
	}

	public void setMessageLength(int messageLength) {
		this.messageLength = messageLength;
	}
	public int getId() {
		return MSG_ID;
	}
}
